package com.gis3c.sys.dao.impl;

import com.gis3c.sys.dao.OrgDao;
import com.gis3c.sys.entry.po.Organization;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * Created by hukekuan on 17-12-6.
 */
@Repository
public class OrgDaoImpl extends SqlSessionDaoSupport implements OrgDao {
    @Resource(name="sqlSessionFactory_sys") private SqlSessionFactory sqlSessionFactory;

    @Override
    public Organization createOrg(Organization org) {
        getSqlSession().insert("OrgSql.createOrg",org);
        return org;
    }

    @Override
    public void updateOrg(Organization org) {

    }

    @Override
    public int deleteOrg(String orgId) {
        return 0;
    }

    @Override
    public int deleteOrgs(String... orgId) {
        return 0;
    }

    @Override
    public Organization findOrgById(String orgId) {
        return null;
    }

    @Override
    public int orgCount(String orgName) {
        return 0;
    }

    @Override
    public List<Organization> orgList() {
        return getSqlSession().selectList("OrgSql.orgList");
    }

    @PostConstruct
    public void injectSessionFactory(){
        super.setSqlSessionFactory(sqlSessionFactory);
    }
}
